package com.hntest.service.impl;

import com.hntest.dao.RealauthDao;
import com.hntest.entity.Pager;
import com.hntest.entity.RealAuth;
import com.hntest.service.RealAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("realAuthService")
public class RealAuthServiceImpl implements RealAuthService {

	@Autowired
	private RealauthDao realAuthDao;
	
	@Override
	public int insertRealauth(RealAuth realAuth) {
		// TODO 自动生成的方法存根
		return realAuthDao.insertRealauth(realAuth);
	}

    @Override
    public int updateRealAuth(RealAuth realAuth) {
        return realAuthDao.updateRealAuth(realAuth);
    }

    @Override
    public List<RealAuth> getListByPage(Pager pager, RealAuth realAuth) {
        //查询总数量
        pager.setTotalCounts(realAuthDao.getCounts(realAuth));
        //将值存入map中
        Map<String, Object> map=new HashMap<>();
        map.put("realAuth", realAuth);
        map.put("pageStart", (pager.getCurrPage()-1)*pager.getPageSize()+1);
        map.put("pageEnd",pager.getCurrPage()*pager.getPageSize());
        //将map中带回的数据保存到list集合中返回
        List<RealAuth> list=realAuthDao.getListByPage(map);
        return list;
    }

    @Override
    public RealAuth selectById(int id) {
        return realAuthDao.selectById(id);
    }

    @Override
    public RealAuth selectByLoginId(int lid) {
        return realAuthDao.selectByLoginId(lid);
    }

}
